package com.fr.chart;

import com.fr.base.XMLable;
import com.fr.base.background.Background;
import com.fr.base.core.GraphHelper;
import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import com.fr.base.xml.BaseXMLUtils;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.chart.axis.SeriesAttrAlpha;
import com.fr.chart.axis.SeriesAttrBackground;
import com.fr.chart.axis.SeriesAttrBorder;
import com.fr.chart.base.equals.Equals;
import com.fr.chart.core.Shadow;
import com.fr.chart.plot.SeriesCollection;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Composite;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Paint;
import java.awt.RenderingHints;
import java.awt.Shape;

public class GeneralInfo
  implements XMLable, GlyphCondition
{
  private static final long serialVersionUID = 8432362457441903617L;
  public static final String XML_TAG = "GI";
  private SeriesAttrAlpha seriesAttrAlpha = new SeriesAttrAlpha();
  private SeriesAttrBorder seriesAttrBorder = new SeriesAttrBorder();
  private SeriesAttrBackground seriesAttrBackground = new SeriesAttrBackground();
  Shadow shadow = null;

  public GeneralInfo()
  {
  }

  public GeneralInfo(Background paramBackground, Color paramColor, int paramInt, float paramFloat)
  {
    getSeriesAttrBackground().setSeriesBackground(paramBackground);
    getSeriesAttrBorder().setBorderColor(paramColor);
    getSeriesAttrBorder().setBorderStyle(paramInt);
    getSeriesAttrAlpha().setAlpha(paramFloat);
  }

  public Background getBackground()
  {
    return getSeriesAttrBackground().getSeriesBackground();
  }

  public void setBackground(Background paramBackground)
  {
    getSeriesAttrBackground().setSeriesBackground(paramBackground);
  }

  public void setSeriesAttrAlpha(SeriesAttrAlpha paramSeriesAttrAlpha)
  {
    this.seriesAttrAlpha = paramSeriesAttrAlpha;
  }

  public SeriesAttrAlpha getSeriesAttrAlpha()
  {
    return this.seriesAttrAlpha;
  }

  public void setSeriesAttrBorder(SeriesAttrBorder paramSeriesAttrBorder)
  {
    this.seriesAttrBorder = paramSeriesAttrBorder;
  }

  public SeriesAttrBorder getSeriesAttrBorder()
  {
    return this.seriesAttrBorder;
  }

  public void setSeriesAttrBackground(SeriesAttrBackground paramSeriesAttrBackground)
  {
    this.seriesAttrBackground = paramSeriesAttrBackground;
  }

  public SeriesAttrBackground getSeriesAttrBackground()
  {
    return this.seriesAttrBackground;
  }

  public Shadow getShadow()
  {
    return this.shadow;
  }

  public void setShadow(Shadow paramShadow)
  {
    this.shadow = paramShadow;
  }

  public int getBorderStyle()
  {
    return getSeriesAttrBorder().getBorderStyle();
  }

  public void setBorderStyle(int paramInt)
  {
    getSeriesAttrBorder().setBorderStyle(paramInt);
  }

  public boolean isRoundBorder()
  {
    return getSeriesAttrBorder().isRoundBorder();
  }

  public void setRoundBorder(boolean paramBoolean)
  {
    getSeriesAttrBorder().setRoundBorder(paramBoolean);
  }

  public Color getBorderColor()
  {
    return getSeriesAttrBorder().getBorderColor();
  }

  public void setBorderColor(Color paramColor)
  {
    getSeriesAttrBorder().setBorderColor(paramColor);
  }

  public float getAlpha()
  {
    return getSeriesAttrAlpha().getAlpha();
  }

  public void setAlpha(float paramFloat)
  {
    getSeriesAttrAlpha().setAlpha(paramFloat);
  }

  public void paint(Graphics paramGraphics, Shape paramShape)
  {
    if (paramShape == null)
      return;
    Graphics2D localGraphics2D = (Graphics2D)paramGraphics;
    Composite localComposite = localGraphics2D.getComposite();
    Paint localPaint = localGraphics2D.getPaint();
    localGraphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    localGraphics2D.setComposite(AlphaComposite.getInstance(3, getAlpha()));
    int i = getBorderStyle();
    if (getBackground() != null)
      getBackground().paint(localGraphics2D, paramShape);
    Shadow localShadow = getShadow();
    if (localShadow != null)
    {
      localShadow.setShape(paramShape);
      if (i != 0)
        localShadow.setOffset(GraphHelper.getLineStyleSize(i));
      localShadow.paint(localGraphics2D);
    }
    if (i != 0)
    {
      localGraphics2D.setPaint(getBorderColor());
      GraphHelper.draw(localGraphics2D, paramShape, i);
    }
    localGraphics2D.setComposite(localComposite);
    localGraphics2D.setPaint(localPaint);
  }

  public void dealCondition(SeriesCollection paramSeriesCollection, int paramInt)
  {
    SeriesAttrAlpha localSeriesAttrAlpha = (SeriesAttrAlpha)paramSeriesCollection.getSeriesCondition(new SeriesAttrAlpha(), paramInt);
    setSeriesAttrAlpha(localSeriesAttrAlpha);
    SeriesAttrBackground localSeriesAttrBackground = (SeriesAttrBackground)paramSeriesCollection.getSeriesCondition(new SeriesAttrBackground(), paramInt);
    setSeriesAttrBackground(localSeriesAttrBackground);
    SeriesAttrBorder localSeriesAttrBorder = (SeriesAttrBorder)paramSeriesCollection.getSeriesCondition(new SeriesAttrBorder(), paramInt);
    setSeriesAttrBorder(localSeriesAttrBorder);
  }

  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof GeneralInfo))
      return false;
    GeneralInfo localGeneralInfo = (GeneralInfo)paramObject;
    if (!(Equals.equals(localGeneralInfo.seriesAttrBackground, this.seriesAttrBackground)))
      return false;
    if (!(Equals.equals(localGeneralInfo.seriesAttrAlpha, this.seriesAttrAlpha)))
      return false;
    return (Equals.equals(localGeneralInfo.seriesAttrBorder, this.seriesAttrBorder));
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if (paramXMLableReader.isChildNode())
    {
      String str1 = paramXMLableReader.getTagName();
      if (str1.equals("SeriesAttrAlpha"))
        this.seriesAttrAlpha = ((SeriesAttrAlpha)paramXMLableReader.readXMLObject(new SeriesAttrAlpha()));
      if (str1.equals("SeriesAttrBackground"))
        this.seriesAttrBackground = ((SeriesAttrBackground)paramXMLableReader.readXMLObject(new SeriesAttrBackground()));
      if (str1.equals("SeriesAttrBorder"))
        this.seriesAttrBorder = ((SeriesAttrBorder)paramXMLableReader.readXMLObject(new SeriesAttrBorder()));
      if (str1.equals("Background"))
      {
        setBackground(BaseXMLUtils.readBackground(paramXMLableReader));
      }
      else
      {
        String str2;
        if (str1.equals("Border"))
        {
          if ((str2 = paramXMLableReader.getAttr("style")) != null)
            setBorderStyle(Integer.parseInt(str2));
          if ((str2 = paramXMLableReader.getAttr("color")) != null)
            setBorderColor(new Color(Integer.parseInt(str2), true));
        }
        else if (str1.equals("Alpha"))
        {
          if ((str2 = paramXMLableReader.getAttr("value")) != null)
            setAlpha(Float.parseFloat(str2));
        }
      }
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    paramXMLPrintWriter.startTAG("GI");
    if (this.seriesAttrBackground != null)
      this.seriesAttrBackground.writeXML(paramXMLPrintWriter);
    if (this.seriesAttrBorder != null)
      this.seriesAttrBorder.writeXML(paramXMLPrintWriter);
    if (this.seriesAttrAlpha != null)
      this.seriesAttrAlpha.writeXML(paramXMLPrintWriter);
    paramXMLPrintWriter.end();
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    GeneralInfo localGeneralInfo = (GeneralInfo)super.clone();
    if (this.seriesAttrBackground != null)
      localGeneralInfo.setSeriesAttrBackground((SeriesAttrBackground)this.seriesAttrBackground.clone());
    if (this.seriesAttrAlpha != null)
      localGeneralInfo.setSeriesAttrAlpha((SeriesAttrAlpha)this.seriesAttrAlpha.clone());
    if (this.seriesAttrBorder != null)
      localGeneralInfo.setSeriesAttrBorder((SeriesAttrBorder)this.seriesAttrBorder.clone());
    return localGeneralInfo;
  }

  public JSONObject toJSONObject()
    throws JSONException
  {
    JSONObject localJSONObject = new JSONObject();
    if (this.seriesAttrAlpha != null)
      localJSONObject.put("seriesAttrAlpha", this.seriesAttrAlpha.toJSONObject());
    if (this.seriesAttrBorder != null)
      localJSONObject.put("seriesAttrBorder", this.seriesAttrBorder.toJSONObject());
    if (this.seriesAttrBackground != null)
      localJSONObject.put("seriesAttrBackground", this.seriesAttrBackground.toJSONObject());
    return localJSONObject;
  }
}